package ui.grafic;

import java.awt.Color;
import java.awt.Graphics;
import java.util.HashMap;
import java.util.Vector;

import datatypes.Edge;

public class NetworkExecutionGrafic extends RosterExecutionGrafic {

	Vector<Line> edges = new Vector<Line>();
	HashMap<String, Line> lineMap = new HashMap<String, Line>();
	Color lineColor = Color.MAGENTA;
	
	class Line {
		private int startx = 0;
		private int starty = 0;
		private int endx = 0;
		private int endy = 0;
		
		private String myName = "noname";
		
		public void paint(Graphics g){
			  g.drawLine( startx*skalierungsfaktor, starty*skalierungsfaktor, endx*skalierungsfaktor, endy*skalierungsfaktor );
		}
		
		public Line(int sx , int sy , int ex , int ey){
			this.startx = sx;
			this.starty = sy;
			this.endx = ex;
			this.endy = ey;
		}
		
		public void paintName(Graphics g){
			g.drawString( myName, (startx-endx+startx)*skalierungsfaktor-5, (starty-endy+starty)*skalierungsfaktor+14 );
	  }
	}
	
	public void removeLine (String edge){
		edges.remove(lineMap.get(edge));
		lineMap.remove(edge);
		this.updateUI();
	}
	
	public NetworkExecutionGrafic(int width, int height, int range) {
		super(width, height, range);
		this.printRange = false;
		// TODO Auto-generated constructor stub
	}

	@Override
	public void paint(Graphics g){
		super.paint(g);
	  	Color activeColor = g.getColor();
	    g.setColor(lineColor);
		for (int i = 0; i < edges.size(); i++){
			edges.get(i).paint(g);
		}
	    g.setColor(activeColor);
	}
//	public void drawEdges (ScenarioDescription scenDesc, PhysicalNetwork phyNet){
//		for (int i=0; i < phyNet.getEdges().size(); i++){
//			HostDescription node1 = scenDesc.getHostDescription(phyNet.getEdges().get(i).getFirstHost().getID());
//			HostDescription node2 = scenDesc.getHostDescription(phyNet.getEdges().get(i).getSecondHost().getID());
//			if (node1 != null && node2 != null){
//				edges.add(new Line(node1.getX(),node1.getY(), node2.getX(), node2.getY()));
//			}
//		}
//		this.repaint();
//	}
	
	
}
